public partial class UILed : UserControl
    {
        public UILed()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
        }

        private Color ledColor = Color.Red;

        public Color LedColor
        {
            get { return ledColor; }
            set
            {
                ledColor = value;
                this.Invalidate();
            }
        }

        private int borderWidth = 5;
        /// <summary>
        /// 外圆宽度
        /// </summary>
        public int BorderWidth
        {
            get { return borderWidth; }
            set
            {
                borderWidth = value;
                this.Invalidate();
            }
        }

        private int gapWidth = 5;
        /// <summary>
        /// 内圆间距
        /// </summary>
        public int GapWidth
        {
            get { return gapWidth; }
            set { gapWidth = value; this.Invalidate(); }
        }



        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            Rectangle rec = new Rectangle(1, 1, this.Width - 2, this.Height - 2);
            g.FillEllipse(new SolidBrush(ledColor), rec);

            Pen p = new Pen(this.BackColor, gapWidth);
            float x = 1 + borderWidth + gapWidth * 0.5f;

            RectangleF recf = new RectangleF(x, x, this.Width - 2 * x, this.Height - 2 * x);
            g.DrawEllipse(p, recf);
        }